package com.ourteam.system.api;

import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.system.dao.SysRoleGroupDAOQueryBean;
import com.ourteam.system.domain.SystemRole;

public class SystemRoleGroupSearchModel extends
		AbstractSearchModel<SysRoleGroupDAOQueryBean> {

	private String roleCode;

	private String roleName;

	private long[] excludeIds;

	@Override
	public String getMappedDAOField(String aProperty) {
		return SystemRole.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(SysRoleGroupDAOQueryBean queryBean)
			throws Exception {

		SysRoleGroupDAOQueryBean.Criteria criteria = queryBean.createCriteria();


		if (StringUtils.isNotBlank(roleCode)) {
			criteria.andRoleCodeLike(roleCode);
		}

		if (StringUtils.isNotBlank(roleName)) {
			criteria.andRoleNameLike(roleName);
		}

		if (ArrayUtils.isNotEmpty(this.excludeIds)) {
			criteria.andIdNotIn(excludeIds);
		}

	}

	public String getRoleCode() {
		return roleCode;
	}

	public void setRoleCode(String roleCode) {
		this.roleCode = roleCode;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public long[] getExcludeIds() {
		return excludeIds;
	}

	public void setExcludeIds(long[] excludeIds) {
		this.excludeIds = excludeIds;
	}

}
